IOMMU/x86: prefill newly allocate page tables
authorJan Beulich <jbeulich@suse.com>
Mon, 25 Jul 2022 13:38:22 +0000 (15:38 +0200)
committerJan Beulich <jbeulich@suse.com>
Mon, 25 Jul 2022 13:38:22 +0000 (15:38 +0200)
commita81d9f9baa8a90db3f30d1f973addc30758a8068
treefad8ad22ac062ff9d2594666aaf00b0492a563b3
parent8c6a4963f07da518a74c35344bc9b28a84a78fee
IOMMU/x86: prefill newly allocate page tables

Page tables are used for two purposes after allocation: They either
start out all empty, or they are filled to replace a superpage.
Subsequently, to replace all empty or fully contiguous page tables,
contiguous sub-regions will be recorded within individual page tables.
Install the initial set of markers immediately after allocation. Make
sure to retain these markers when further populating a page table in
preparation for it to replace a superpage.

The markers are simply 4-bit fields holding the order value of
contiguous entries. To demonstrate this, if a page table had just 16
entries, this would be the initial (fully contiguous) set of markers:

index  0 1 2 3 4 5 6 7 8 9 A B C D E F
marker 4 0 1 0 2 0 1 0 3 0 1 0 2 0 1 0

"Contiguous" here means not only present entries with successively
increasing MFNs, each one suitably aligned for its slot, and identical
attributes, but also a respective number of all non-present (zero except
for the markers) entries.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-by: Paul Durrant <paul@xen.org>
xen/arch/x86/include/asm/iommu.h
xen/drivers/passthrough/amd/iommu-defs.h
xen/drivers/passthrough/amd/iommu_map.c
xen/drivers/passthrough/amd/pci_amd_iommu.c
xen/drivers/passthrough/vtd/iommu.c
xen/drivers/passthrough/vtd/iommu.h
xen/drivers/passthrough/x86/iommu.c